package com.cskaoyan;

import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class MyResultSetHandler implements ResultSetHandler {


    @Override
    public Object handle(ResultSet rs) throws SQLException {

        List<Account> accountList = new ArrayList<Account>();

        while (rs.next()) {

            int id = rs.getInt("id");
            String name = rs.getString("name");
            int money = rs.getInt("money");

            Account account = new Account();
            account.setId(id);
            account.setName(name);
            account.setMoney(money);

            accountList.add(account);
        }


        return accountList;
    }
}
